<template>
  <!-- 出入库管理 -->
  <div class="app-page">
    <el-tabs
      ref="outPutStorageManageTab"
      v-model="activeTabName"
      type="card"
    >
      <el-tab-pane v-if="$hasTabPermission(70301)" label="调拨计划" name="allotPlan">
        <allot-plan v-if="activeTabName ==='allotPlan'" />
      </el-tab-pane>
      <el-tab-pane v-if="$hasTabPermission(70302)" label="调拨单" name="transferManage">
        <transfer-manage v-if="activeTabName ==='transferManage'" />
      </el-tab-pane>
      <el-tab-pane v-if="$hasTabPermission(70303)" label="出库单" name="outStorage">
        <outStorage v-if="activeTabName ==='outStorage'" ref="outStorage" :store-map="storeMap" :storage-store-map="storageStoreMap" :truck-map="truckMap" :driver-map="driverMap" :escort-map="escortMap" />
      </el-tab-pane>
      <el-tab-pane v-if="$hasTabPermission(70304)" label="入库单" name="putStorage">
        <putStorage v-if="activeTabName ==='putStorage'" ref="putStorage" :store-map="storeMap" :storage-store-map="storageStoreMap" :truck-map="truckMap" :driver-map="driverMap" :escort-map="escortMap" />
      </el-tab-pane>
      <el-tab-pane v-if="$hasTabPermission(70305)" label="气瓶收回入库" name="cylindersBack">
        <cylindersBack v-if="activeTabName ==='cylindersBack'" ref="cylindersBack" :storage-store-map="storageStoreMap" :escort-map="escortMap" />
      </el-tab-pane>
    </el-tabs>
  </div>
</template>

<script>
  import { selectOrgSNNo, queryTruckNoList, queryDriverList, queryEscortList } from '@/api'
  import allotPlan from './allotPlan'
  import transferManage from './transferManage'
  import outStorage from './outStorage'
  import putStorage from './putStorage'
  import cylindersBack from './cylindersBack'
  export default {
    name: 'outPutStorageManage',
    components: {
      allotPlan, transferManage, outStorage, putStorage, cylindersBack
    },
    data() {
      return {
        activeTabName: 'allotPlan',
        storeMap: [],
        storageStoreMap: [],
        truckMap: [],
        driverMap: [],
        escortMap: []
      }
    },
    computed: {

    },
    async created() {
      await this.initStoreMap()
    },
    mounted() {
      this.activeTabName = this.$refs.outPutStorageManageTab.panes.length ? this.$refs.outPutStorageManageTab.panes[0].name : ''
    },
    methods: {
      async initStoreMap() {
        // selectOrgSNNoAndReType({
        //   currentPage: 1,
        //   pageSize: 9999,
        //   reType: 4
        // }).then((res) => {
        //   this.storeMap = res.data
        // })
        selectOrgSNNo({
          orgSNNo: '',
          reType: 4
        }).then(res => {
          const rightStoreMap = res.data.filter(item => {
            return item.reType === 1 || item.reType === 3 || item.reType === 6
          })
          this.storeMap = rightStoreMap
          this.storageStoreMap = rightStoreMap
        })
        // 查询所有车辆
        const query = {
          truckType: 3
        }
        const res = await queryTruckNoList(query)
        this.truckMap = res.data
        // 查询所有司机
        const res1 = await queryDriverList()
        this.driverMap = res1.data
        // 查询所有押运员
        const res2 = await queryEscortList()
        this.escortMap = res2.data
      }
    }
  }
</script>

<style lang="scss" scoped>
.app-page {
  padding: 0;
  margin: 0;
  /deep/.el-tabs__header {
    margin: 0 0 10px;
  }
}
</style>
